/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.srcptit.trainning.giangnd.btvn1;

import java.util.Scanner;

/**
 *
 * @author GIANG
 */
public class B1M2 {
    static void nhap(float a[], int n) {
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < n; i++) {
			System.out.print("\nA[" + i + "]=");
			a[i] = sc.nextFloat();
		}
	}

	static void xuat(float a[], int n) {
		for (int i = 0; i < n; i++)
			System.out.print(a[i] + " ");
	}

	static void sapxep(float a[], int n) {
		for (int i = 0; i < n; i++)
			for (int j = n - 1; j > i; j--)
				if (a[j] < a[i]) {
					float tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
				}
		System.out.println("\nSau khi sap xep:");
		xuat(a, n);
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		System.out.print("n=");
		n = sc.nextInt();
		float a[] = new float[n];
		nhap(a, n);
		xuat(a, n);
		sapxep(a, n);
	}
}
